/*
 * Copyright (c) 2024. hallele, Inc All rights reserved.
 */

package cn.hallele.ms.demo.model.entity;

import jakarta.persistence.*;
import lombok.*;

import java.io.Serial;
import java.io.Serializable;

/**
 * hallele_ms_demo
 *
 * @author anle5
 * @since 2024/9/15 15:06
 */
@Getter
@Setter
@Entity
@Table(name = "dm_demo")
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DemoEntity implements Serializable {
    @Serial
    private static final long serialVersionUID = 9209048434309468670L;

    /**
     * 身份唯一标识
     * 生成策略: 从表key_generator中读取
     * name: TableGenerator唯一标识
     * pkColumnName：生成策略所对应键值的名称
     * pkColumnValue：键当前所生成的值，它的值将会随着每次创建累加
     * initialValue: 初始值
     * allocationSize: 递增至
     */
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "DemoEntity")
    @TableGenerator(name = "DemoEntity",
            table = "key_generator",
            pkColumnName = "gen_name",
            valueColumnName = "gen_value",
            pkColumnValue = "dm_demo",
            initialValue = 1,
            allocationSize = 1
    )
    @Column(name = "id")
    private Integer id;

    /**
     * 样例内容
     */
    @Column(name = "text")
    private String text;
}
